/*	Interactive Gravitational Simulator
	Project: IGS Core
	File: Vector.h
	Author: Mike Bantegui <mbante2@gmail.com>, Hofstra University 
	Copyright (C) 2012 - 2013 Mike Bantegui

	This file is part of the IGS software package for simulating
	the N-Body problem in real-time. This was developed as part
	of a departmental honors thesis project at Hofstra University
	in the Spring 2012 semester.

	IGS is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	IGS is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#ifndef IGS_VECTOR_H
#define IGS_VECTOR_H

#include <iosfwd>

namespace IGS
{

// Represents a 3D Euclidean vector
struct Vector
{
	// The x coordinate
	double x;
	// The y coordinate
	double y;
	// The z coordinate
	double z;

	Vector();
	Vector(const double x, const double y, const double z);

	const double &operator[](const int i) const;
	double &operator[](const int i);

	void Zero();

	Vector &operator+=(const Vector &rhs);
	Vector &operator-=(const Vector &rhs);
	Vector &operator/=(const double rhs);

	friend Vector operator+(const Vector &lhs, const Vector &rhs);
	friend Vector operator-(const Vector &lhs, const Vector &rhs);
	friend Vector operator*(const Vector &lhs, const double rhs);
	friend Vector operator*(const double lhs, const Vector &rhs);
	friend Vector operator/(const Vector &lhs, const double rhs);

	friend double Dot(const Vector &lhs, const Vector &rhs);
	friend double Distance(const Vector &a, const Vector &b);
	friend double Length(const Vector &v);
	friend double LengthSq(const Vector &v);
	friend Vector Cross(const Vector &lhs, const Vector &rhs);

	friend std::ostream &operator<<(std::ostream &os, const Vector &v);
	friend std::istream &operator>>(std::istream &is, Vector &v);
};

double Random(const double min, const double max);
Vector RandomUniform(const double r);
Vector RandomInSphere(const double r);
Vector RandomSpherical(const double r);

}

#endif